package com.rong.shop.service.impl;

import com.rong.shop.mapper.AddressDistrictMapper;
import com.rong.shop.pojo.AddressDistrict;
import com.rong.shop.service.IAddressDistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressDistrictServiceImpl implements IAddressDistrictService {

    @Autowired
    private AddressDistrictMapper addressDistrictMapper;

    @Override
    public List<AddressDistrict> findByParent(String parent) {
        List<AddressDistrict> datas = addressDistrictMapper.findByParent(parent);
        // 显示该显示的部分，节省流量
        for (AddressDistrict data : datas) {
            data.setId(null);
            data.setParent(null);
        }
        return datas;
    }

    @Override
    public String findNameByCode(String code){
        String name = addressDistrictMapper.findNameByCode(code);
        return name;
    }

}
